export const WINDOW_ANIMATION_TIME = 250;
export const WORKSPACE_SPACING = 100;
-export const WorkspaceGroup = GObject.registerClass(
-class WorkspaceGroup extends Clutter.Actor {
- _init(workspace, monitor, movingWindow) {
- super._init({
+export const BaseWorkspaceGroup = GObject.registerClass(
+class BaseWorkspaceGroup extends Clutter.Actor {
+ constructor(workspace, monitor) {
+ super({
width: monitor.width,
height: monitor.height,
clip_to_allocation: true,
this._workspace = workspace;
this._monitor = monitor;
- this._movingWindow = movingWindow;
this._windowRecords = [];
- if (this._workspace) {
- this._background = new Meta.BackgroundGroup();
-
- this.add_child(this._background);
-
- this._bgManager = new Background.BackgroundManager({
- container: this._background,
- monitorIndex: this._monitor.index,
- controlPosition: false,
- });
- this._createDesktopWindows();
- }
-
+ this._createBackground();
this._createWindows();
this.connect('destroy', this._onDestroy.bind(this));
- global.display.connectObject('restacked',
- this._syncStacking.bind(this), this);
}
get workspace() {
return this._workspace;
}
- _shouldShowWindow(window) {
- if (!window.showing_on_its_workspace() || this._isDesktopWindow(window))
- return false;
-
- if (window.is_override_redirect())
- return false;
-
- if (!this._windowIsOnThisMonitor(window))
- return false;
-
- const isSticky =
- window.is_on_all_workspaces() || window === this._movingWindow;
-
- // No workspace means we should show windows that are on all workspaces
- if (!this._workspace)
- return isSticky;
-
- // Otherwise only show windows that are (only) on that workspace
- return !isSticky && window.located_on_workspace(this._workspace);
- }
-
- _syncStacking() {
- const windowActors = global.get_window_actors().filter(w =>
- this._shouldShowWindow(w.meta_window));
-
- let lastRecord;
- const bottomActor = this._background ?? null;
-
- for (const windowActor of windowActors) {
- const record = this._windowRecords.find(r => r.windowActor === windowActor);
-
- this.set_child_above_sibling(record.clone,
- lastRecord ? lastRecord.clone : bottomActor);
- lastRecord = record;
- }
+ _shouldShowWindow(_window) {
+ throw new GObject.NotImplementedError();
}
_isDesktopWindow(metaWindow) {
return intersects;
}
- _createDesktopWindows() {
- const desktopActors = global.get_window_actors().filter(w => {
- return this._isDesktopWindow(w.meta_window) && this._windowIsOnThisMonitor(w.meta_window);
- });
- desktopActors.map(a => this._createClone(a)).forEach(clone => this._background.add_child(clone));
+ _createBackground() {
}
_createWindows() {
_onDestroy() {
this._removeWindows();
+ }
+});
+
+export const WorkspaceGroup = GObject.registerClass(
+class WorkspaceGroup extends BaseWorkspaceGroup {
+ constructor(workspace, monitor, movingWindow) {
+ super(workspace, monitor);
+
+ this._movingWindow = movingWindow;
+
+ global.display.connectObject('restacked',
+ () => this._syncStacking(), this);
+ }
+
+ _shouldShowWindow(window) {
+ if (!window.showing_on_its_workspace() || this._isDesktopWindow(window))
+ return false;
+
+ if (window.is_override_redirect())
+ return false;
+
+ if (!this._windowIsOnThisMonitor(window))
+ return false;
+
+ const isSticky =
+ window.is_on_all_workspaces() || window === this._movingWindow;
+
+ // No workspace means we should show windows that are on all workspaces
+ if (!this._workspace)
+ return isSticky;
+
+ // Otherwise only show windows that are (only) on that workspace
+ return !isSticky && window.located_on_workspace(this._workspace);
+ }
+
+ _syncStacking() {
+ const windowActors = global.get_window_actors().filter(w =>
+ this._shouldShowWindow(w.meta_window));
+
+ let lastRecord;
+ const bottomActor = this._background ?? null;
+
+ for (const windowActor of windowActors) {
+ const record = this._windowRecords.find(r => r.windowActor === windowActor);
+
+ this.set_child_above_sibling(record.clone,
+ lastRecord ? lastRecord.clone : bottomActor);
+ lastRecord = record;
+ }
+ }
+
+ _createBackground() {
+ if (!this._workspace)
+ return;
+
+ this._background = new Meta.BackgroundGroup();
+ this.add_child(this._background);
+
+ this._bgManager = new Background.BackgroundManager({
+ container: this._background,
+ monitorIndex: this._monitor.index,
+ controlPosition: false,
+ });
+ this._createDesktopWindows();
+ }
+
+ _createDesktopWindows() {
+ const desktopActors = global.get_window_actors().filter(w => {
+ return this._isDesktopWindow(w.meta_window) && this._windowIsOnThisMonitor(w.meta_window);
+ });
+ desktopActors.map(a => this._createClone(a)).forEach(clone => this._background.add_child(clone));
+ }
+
+ _onDestroy() {
+ super._onDestroy();
if (this._workspace)
this._bgManager.destroy();